package com.zhiyou100.review.day005.test;

/**
 * @author yang
 * @packageName ReferenceTypeDemo
 * @className com.zhiyou100.review.day005.test
 * @Description TODO java 引用传递测试
 * @date 6/13/20
 */
public class ReferenceTypeDemo {
    public static void main(String[] args) {
        Writer a = new Writer(18);
        Writer b = new Writer(18);
        modify(a, b);

        System.out.println(a.getAge());
        // 30
        System.out.println(b.getAge());
        // 18


    }

    private static void modify(Writer a1, Writer b1) {
        a1.setAge(30);

        b1 = new Writer(18);
        // new 了一个新的对象和 传进来的 b1 没有关系了
        b1.setAge(30);

    }

}

class Writer {
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Writer(int age) {
        this.age = age;
    }
}
